package com.shhm.common.utils;


/**
 * @author JackZ
 * @version 1.0
 * @description: 字符床工具类
 * @date 2025/7/15 下午3:06
 */
public class StringUtil extends org.apache.commons.lang3.StringUtils {
    /** 空字符串 */
    private static final String NULLSTR = "";

    /** 下划线 */
    private static final char SEPARATOR = '_';

    /** 星号 */
    private static final char ASTERISK = '*';

    /**
     * 获取参数不为空值
     *
     * @param value defaultValue 要判断的value
     * @return value 返回值
     */
    public static <T> T nvl(T value, T defaultValue)
    {
        return value != null ? value : defaultValue;
    }
    public static String substring(final String str, int start)
    {
        if (str == null)
        {
            return NULLSTR;
        }

        if (start < 0)
        {
            start = str.length() + start;
        }

        if (start < 0)
        {
            start = 0;
        }
        if (start > str.length())
        {
            return NULLSTR;
        }

        return str.substring(start);
    }

    public static String createRandomNumber(String beforeStr) {
        String str=beforeStr;
        long timestamp = System.currentTimeMillis();
        str+=timestamp;
        int random = (int) (Math.random() * 1000);
        str+=random;
        return str;
    }
}
